using System;
using System.Collections.Generic;
using System.Linq;

namespace PokerStar.Core.Rules
{
    public class NothingRule : BasicRule
    {
        public NothingRule(IRule next)
            : base(next)
        {
        }

        protected override GameResult Match(RuleContext context)
        {
            //var rs = new NothingGameResult();
            //rs.Cards = cards.OrderByDescending(p => p.Number, new CardNumberComparer()).Take(5).ToList();
            //rs.Evidence = rs.Cards.Select(p => CardNumberComparer.Card2Int(p.Number)).ToList();
            //return rs;

            var rs = new NothingGameResult();
            rs.Cards = context.GroupByNumber.Take(5).Select(p => p.First()).ToList();
            rs.Evidence = rs.Cards.Select(p => CardNumberComparer.Card2Int(p.Number)).ToList();
            return rs;
        }
    }

    public class NothingGameResult : GameResult
    {
        public override string ToString()
        {
            return string.Format("Nothing -> {0} {1} {2} {3} {4}", Cards[0], Cards[1], Cards[2], Cards[3], Cards[4]);
        }

        public override ResultLevel Level
        {
            get { return ResultLevel.Nothing; }
        }
    }
}